package com.sharding.sphere.dao;

import com.sharding.sphere.entity.OrderDO;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface OrderDao {
    @Insert("insert into t_order(order_id,user_id,order_amount,order_desc,order_state) values(#{orderId},#{userId},#{orderAmount},#{orderDesc},#{orderState})")
    int insertOrder(OrderDO orderDO);

    @Select("select id,order_id,user_id,order_amount,order_desc,order_state from t_order where id = #{id} and order_id=#{orderId}")
    @Results(id = "stockMap", value = {
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "order_id", property = "orderId", jdbcType = JdbcType.BIGINT),
            @Result(column = "user_id", property = "userId", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_amount", property = "orderAmount", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_desc", property = "orderDesc", jdbcType = JdbcType.VARCHAR),
            @Result(column = "order_state", property = "orderState", jdbcType = JdbcType.VARCHAR),
    })
    List<OrderDO> getOrder(@Param("id") Long id, @Param("orderId") Long orderId);


    @Select("select id,order_id,user_id,order_amount,order_desc,order_state from t_order")
    @Results(id = "stockMap1", value = {
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "order_id", property = "orderId", jdbcType = JdbcType.BIGINT),
            @Result(column = "user_id", property = "userId", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_amount", property = "orderAmount", jdbcType = JdbcType.BIGINT),
            @Result(column = "order_desc", property = "orderDesc", jdbcType = JdbcType.VARCHAR),
            @Result(column = "order_state", property = "orderState", jdbcType = JdbcType.VARCHAR),
    })
    List<OrderDO> getAllOrder();

}
